package com.yaya.spring.ioc.proEdit;

import java.beans.PropertyEditorSupport;

//Finally, we use CustomEditorConfigurer to register the new PropertyEditor with the ApplicationContext
//which will then be able to use it as needed
//需要使用CustomEditorConfigurer类型进行注册转换器
public class AddressEditor extends PropertyEditorSupport {
	
	//参数text,就是从xml中拿到的字符串: kunshan,xueyuan,China
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		String[] str = text.split(",");
		String city = str[0];
		String street = str[1];
		String country = str[2];
		Address add = new Address(city, street, country);
		
		//把新的值设置到对象中
		setValue(add);
	}

}
